<template>
	<view>
		<scroll-view class="scroll-view" scroll-y="true" :style="'height:'+scriptHeight+'px'">
			<view class="poetry">
				<view class="item" v-for="(item,index) in poetryList" :key="index" @click="clickPoetry(item.id)">
					<view class="item-text">{{item.content}}</view>
					<view class="item-button">
						<view class="left">{{item.title}}-{{item.dynasty}}-{{item.author}}</view>
						<view class="right">{{item.hit}} 人浏览</view>
					</view>
				</view>
			</view>
			<view class="poet">
				<view class="item" v-for="(item,index) in poetList" :key="index" @click="clickPoet(item.id)">
					<view class="avatar"><image :src="item.avatar"></image></view>
					<view class="content">
						<view class="name">{{item.name}}-{{item.dynasty}}</view>
						<!-- <view class="content-dynasty">{{item.dynasty}}</view> -->
						<view class="desc">{{item.descr}}</view>
					</view>
				</view>
			</view>
			<view class="chengyu">
				<view class="item" v-for="(item,index) in chengyuList" :key="index" @click="clickChengyu(item.id)">
					<view class="content">
						<view class="title">{{item.title}}</view>
						<view class="desc">{{item.desc}}</view>
					</view>
					<view class="icon">></view>
				</view>
				
				
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import unils from "../../unils/utils.js"
	export default {
		data() {
			return {
				'type':0,
				'search':'',
				'scriptHeight':400,
				'poetList':[],
				'chengyuList':[],
				'poetryList':[],
			}
		},
		onReady() {
			this.scriptHeight = uni.getSystemInfoSync().windowHeight;
		},
		onLoad(option) {
			this.type = option.type;
			this.search = option.search;
			this.type = 1;
			this.search = '静夜思';
			this.getData();
		},
		methods: {
			clickPoetry:function(id){
				uni.navigateTo({
					url:"../article_sc/article_sc?id="+id,
				})
			},
			clickChengyu:function(id){
				uni.navigateTo({
					url:"../article_cy/article_cy?id="+id,
				})
			},
			clickPoet:function(id){
				// console.log(id);
				uni.navigateTo({
					url:"../shici/list?poet_id="+id,
				})
			},
			getData:function(){
				let that = this;
				that.flag = false;
				uni.request({
					url: that.websiteUrl+'/search',
					method:'GET',
					header: {
							'x-requested-with': 'xmlhttprequest' //自定义请求头信息
						},
					data:{
						'type':that.type,
						'search':that.search,
					},
					success:(res)=>{
						if(res.data.code != 1){
							uni.showToast({
								title:res.data.msg,
								duration:2000,
								icon:'none',
							})
						} else {
							that.chengyuList = res.data.data.chengyu;
							that.poetList = res.data.data.poet;
							that.poetryList = res.data.data.poetry;
						}
					}
				})	
				
			},
			
		}
	}
</script>

<style lang="scss">
.scroll-view{
	height: 450px;
	background-color: $uni-scroll-bg-clolr;
	.chengyu{
		.item{
			background-color: $uni-bg-color;
			border-radius: 5px;
			margin: 10px;
			display: flex;
			//justify-content: center;
			align-items: center;
			padding: 10px;
			color: $uni-text-color;
			.content{
				width:100%;
				.title{
					font-size: 15px;
					margin-bottom: 3px;
				}
				.desc{
					font-size: 13px;
				}
			}
			.icon{
				flex-shrink: 0;
				margin-right: 10px;
			}
		}
		
	}
	.poet{
		margin-top: 20px;
		.item{
			background-color: $uni-bg-color;
			margin: 10px;
			border-radius: 5px;
			display: flex;
			padding:5px;
			.avatar{
				image{
					width:70px;
					height:70px;
					border-radius: 5px;
				}
			}
			.content{
				margin-left: 10px;
				font-size:13px;
				color: $uni-text-color;
				.name{
					font-size:15px;
					font-weight: bold;
					// background-color: #007AFF;
				}
				.content-dynasty{
					// background-color: #F07373;
				}
				.desc{
					margin-top: 3px;
					line-height: 20px;
				}
			}
		}
	}
	.poetry{
		
		.item{
			font-size: 15px;
			margin: 15px 10px;
			background-color: #FFFFFF;
			padding:10px 10px;
			border-radius: 3px;
			color:$uni-text-color;
			
			.item-text{
				
			}
			.item-button{
				font-size:12px;
				display: flex;
				// justify-content: flex-end;
				margin-top: 10px;
				.left{
					font-size: 14px;
					font-weight: bold;
					// display: flex;
					// justify-content: flex-start;
					width: 100%;
					color:$uni-text-color;
				}
				.right{
					flex-shrink: 0;
					
					color:$uni-primary-color;
					display: flex;
					justify-content: flex-end;
					padding-right: 3px;
				}
			}
		}
	}
}


</style>
